gusucode.com > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM源码程序 > 支持向量机工具箱 - LIBSVM OSU_SVM LS_SVM\stprtool\datasets\x2pgm.m
function x2pgm(X,width,height,fname) % x2pgm(X,fname) % % X2PGM write an image from the vector X to the file fname % in the PGM format. The vector is supposed to be double % and normalized to <0,1>. The arguments width and height % determine the shape of the image. % % Input: % X [size x 1] contains input image of given size. % width [1x1] width of the image. % height [1x1] height of the image. % fname [string] name of the file where the image is to be written. % % % See also PGM2X % % Statistical Pattern Recognition Toolbox, Vojtech Franc, Vaclav Hlavac % (c) Czech Technical University Prague, http://cmp.felk.cvut.cz % Written Vojtech Franc (diploma thesis) % Modifications % 26-feb-2001 V.Franc fid=fopen(fname, 'w' ); fprintf(fid, 'P5\n'); fprintf(fid, '%d %d\n',width, height ); fprintf(fid, '255\n' ); X=uint8(X*255); fwrite(fid,X,'uchar'); fclose(fid); return;